Skip to content

feat: add TripAdvisor username scan module#428

Merged
kaifcodec merged 7 commits into
kaifcodec:mainfrom
brunolm:feat/add-tripadvisor-username-module
Jul 23, 2026
Merged

feat: add TripAdvisor username scan module#428
kaifcodec merged 7 commits into
kaifcodec:mainfrom
brunolm:feat/add-tripadvisor-username-module

Conversation

@brunolm

@brunolm brunolm commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Adds a username-existence scan module for TripAdvisor, plus a small reusable core helper for sites behind TLS-fingerprint bot walls.

How it works

  • GET https://www.tripadvisor.com/Profile/{username} to determine existence.
  • Found → HTTP 200, or a 301/302 that redirects back to /Profile/... (TripAdvisor case-canonicalizes handles, e.g. travelbug/Profile/TRAVELBUG, so a redirect to a profile URL still confirms the account exists).
  • Not found → HTTP 404.
  • On a hit, profile metadata (name, bio, hometown, join date, website, avatar) is enriched from TripAdvisor's persisted GraphQL query. Enrichment is best-effort and fully guarded, so a parsing/network failure never turns a found account into an error.

Why the new dependency (curl_cffi)

Since this module was first written, TripAdvisor moved behind DataDome, which fingerprints the TLS handshake (JA3/JA4) rather than the User-Agent. Python's default TLS stack (used by httpx) is rejected with 403 no matter which headers or cookies you send — so the original plain-httpx approach no longer works.

The fix needs two things together:

  1. curl_cffi with impersonate="chrome" — replicates a real Chrome TLS handshake so the fingerprint check passes.
  2. A one-time session warm-up — hitting the homepage first yields DataDome's clearance cookie, which the profile and GraphQL requests then reuse.

Neither alone is enough:

Approach Homepage Profile Works?
httpx + real Chrome UA + full headers, no warm-up 403 403
httpx + session warm-up (cookies) 403 403
curl_cffi chrome, no warm-up 403
curl_cffi chrome + warm-up 403 200

This lives in a new reusable core helper — user_scanner/core/impersonate.py (impersonate_validate / impersonate_request) — that mirrors generic_validate but routes through a warmed, cookie-persistent impersonating session. Any other module that hits a DataDome/Cloudflare TLS wall can reuse it.

curl_cffi>=0.7,<1 is added to pyproject.toml and requirements.txt.

Testing

  • Verified live against multiple real handles (brunolm7, globetrotter, john, maria, david, susan) → Found with correct metadata; well-formed nonexistent handles → Not Found.
  • New tests/test_impersonate.py covers warm-up-once/session-reuse and error handling.
  • Full suite passes (only the pre-existing *_unreadable tests fail, and only on Windows).

Context

This fills a real coverage gap: Maigret and WhatsMyName check TripAdvisor usernames but user-scanner did not.

@kaifcodec kaifcodec added the need-extra-changes Some files or parts of the code may require additional edits or updates for it work properly. label Jul 19, 2026
Capture the member name, about text and avatar from OpenGraph tags via
Result.taken(extra=...) when a profile is found.
@brunolm

brunolm commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

DataDome

@brunolm brunolm closed this Jul 19, 2026
TripAdvisor sits behind DataDome, which fingerprints the TLS handshake and
returns 403 to Python's default HTTP stack regardless of headers. Route the
module through a warmed, browser-impersonating curl_cffi session: a one-time
homepage warm-up obtains the clearance cookie, and Chrome TLS impersonation
clears the fingerprint check.

Add reusable impersonate_validate/impersonate_request core helpers so other
bot-walled modules can reuse the same warmed session, and fetch profile
metadata (name, bio, hometown, joined, website, avatar) from TripAdvisor's
persisted GraphQL query. Parsing is null-safe and fully guarded so metadata
enrichment never turns a found account into an error.
@brunolm brunolm reopened this Jul 22, 2026
Drop the leftover `re` import in tripadvisor.py (the website decoder no longer
uses a regex).

curl_cffi is fully typed but was not installed in the lint job. Install it there
alongside httpx so mypy checks against its real types, and fix the two genuine
mismatches instead of masking them: narrow the request method to
Literal["GET", "POST"] and waive only the browser-name Literal on the
impersonate argument.
@brunolm
brunolm force-pushed the feat/add-tripadvisor-username-module branch from 3aa7310 to e741806 Compare July 22, 2026 12:22
@kaifcodec

Copy link
Copy Markdown
Owner

@brunolm we had recently introduced -t and -C flag in PR #416

One small thing I just noticed regarding timeout handling.

The new impersonate.py helper currently uses a hardcoded DEFAULT_TIMEOUT = 15.0, so it doesn't respect the global -t timeout flag that users can set from the CLI. This is a bit inconsistent with make_request() and generic_validate(), which already use get_global_timeout().

Could you update both impersonate_request() and _get_warm_session() to do something like:

global_timeout = get_global_timeout()
timeout = global_timeout if global_timeout is not None else DEFAULT_TIMEOUT

That way, modules such as SpankBang, TripAdvisor, and Pornhub will automatically honor the -t flag just like the rest of the codebase.

brunolm added 2 commits July 22, 2026 14:09
impersonate_request() and the session warm-up used a hardcoded DEFAULT_TIMEOUT,
so they ignored the CLI -t flag. Route both through a _timeout() helper that
reads get_global_timeout() and falls back to DEFAULT_TIMEOUT, matching
make_request() / generic_validate().
@brunolm

brunolm commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

@kaifcodec that should be addressed now. I've also tested -C 60 and it seems to work normally.

@kaifcodec kaifcodec added the user module addition PRs or issues related to new user_scan module additions label Jul 23, 2026
@kaifcodec
kaifcodec merged commit ffaf8c4 into kaifcodec:main Jul 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-extra-changes Some files or parts of the code may require additional edits or updates for it work properly. user module addition PRs or issues related to new user_scan module additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants